﻿using AntMovement.Core;
using AntMovement.Core.IParameter;
using AntMovement.Parameter;
using Prism.Commands;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AntMovement.Menu.HardControl.ViewModels
{
    public class RoundTripMotionViewModel
    {
        public TemporaryParameter Temporary { get; set; }
        private ILog _log;
        public RoundTripMotionViewModel(IAxisParameter axisParameter, ITemporaryParameter temporaryParameter)
        {
            Temporary = (TemporaryParameter)temporaryParameter;
            if (Temporary.PointRoundTrips.Count == 0)
            {
                foreach (var item in ((AxisParameter)axisParameter).AxisDataSet)
                {
                    Temporary.PointRoundTrips.Add(new Parameter.Model.PointRoundTripModel()
                    {
                        Name = item.Name,
                        AxisID = item.AxisID,
                        Count = 5,
                    });
                }
            }
        }

        public DelegateCommand<string> SelectionMove => new DelegateCommand<string>(sender =>
        {
            if (!Temporary.SystemStatus.ManualOperation)
            {
                return;
            }
            if (!Temporary.RunPointRound)
            {
                Temporary.NamePointRound = sender;
                Temporary.RunPointRound = true;
                _log.Debug("开始往返运动...");
            }
            else
            {
                Temporary.NamePointRound = default;
                Temporary.RunPointRound = true;
                _log.Debug("停止往返运动...");
            }
        });
    }
}
